//
//  HMAdvisorySetting.swift
//  HealthMonitoring
//
//  Created by 珠海正杰 on 2018/9/17.
//  Copyright © 2018年 YTYanK. All rights reserved.
//

import UIKit
import SwiftForms

class HMAdvisorySetting: FormViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let form = FormDescriptor()
//        form.title = "Example form"
        
        //第一个section分区
        let section1 = FormSectionDescriptor(headerTitle: nil, footerTitle: nil)
        section1.headerViewHeight = 0
        
        let row1 = FormRowDescriptor(tag: "title1", type: .label, title: "咨询设置")
        row1.configuration.cell.appearance["titleLabel.font"] = UIFont.boldSystemFont(ofSize: 18.0)
        section1.rows.append(row1)
//        let pi = UIPickerView()
//        pi.backgroundColor = UIColor.blue
        let row = FormRowDescriptor(tag: "地区", type: .picker, title: "地区选择")
    
        row.configuration.selection.options = ["123", "234"] as [AnyObject]
//        let pi =  UIPickerView()
//        pi.backgroundColor = .red
//        row.configuration.cell.appearance["picker"] = pi
        row.configuration.cell.appearance["valueLabel.textColor"] = configure.shareConfigure.HMColor1
        row.configuration.selection.optionTitleClosure = { value in
            print("-----xxx--->", value)
            return value as! String
        }
        row.value = "123" as AnyObject  //默认值
        section1.rows.append(row)
        
        let row2 =  FormRowDescriptor(tag: "全科", type: .booleanSwitch, title: "全科")
//        row2.configuration.button.didSelectClosure = { value in
//            print("---->>>", value.tag)
//        }
        row2.configuration.cell.didUpdateClosure = { row in
            print("--- 值发生改变 ---")
            print("type：\(row2.type)")
            print("tag：\(row2.tag)")
            print("title：\(row2.title!)")
            print("value：\(row2.value!)")
        }
        section1.rows.append(row2)
        
        
        let row3 = FormRowDescriptor(tag: "咨询方式", type: .picker, title: "咨询方式")
        row3.configuration.cell.appearance["valueLabel.textColor"] = configure.shareConfigure.HMColor1
        row3.configuration.selection.options = ["任意","图片咨询", "视频咨询"] as [AnyObject]
        row3.configuration.selection.optionTitleClosure = { value in
            return value as! String
        }
        row3.value = "任意" as AnyObject
        section1.rows.append(row3)
        
        
        
        let section2 = FormSectionDescriptor(headerTitle: nil, footerTitle: nil)
        section2.headerViewHeight = 12
        let row1_2 = FormRowDescriptor(tag: "title1", type: .label, title: "可接受最低价格")
        row1_2.configuration.cell.appearance["titleLabel.font"] = UIFont.boldSystemFont(ofSize: 18.0)
        section2.rows.append(row1_2)
        
        
        let row2_2 = FormRowDescriptor(tag: "图文价格", type: .picker, title: "图文咨询价格")
        row2_2.configuration.cell.appearance["valueLabel.textColor"] = configure.shareConfigure.HMColor1
        row2_2.configuration.selection.options = ["10元", "20元"] as [AnyObject]
        row2_2.configuration.selection.optionTitleClosure = { value in
            
            return value as! String
        }
        row2_2.value = "20元" as AnyObject
        section2.rows.append(row2_2)
        
        
        let row3_2 = FormRowDescriptor(tag: "视频价格", type: .picker, title: "视频咨询价格")
        row3_2.configuration.cell.appearance["valueLabel.textColor"] = configure.shareConfigure.HMColor1
        row3_2.configuration.selection.options = ["15元", "25元"] as [AnyObject]
        row3_2.configuration.selection.optionTitleClosure = { value in
            
            return value as! String
        }
        row3_2.value = "15元" as AnyObject
        section2.rows.append(row3_2)
        
        
        form.sections = [section1, section2]
        self.form = form
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
